<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
    request.setAttribute("contextPath", request.getContextPath());
%>
<head>
<title>User Register</title>
</head>
<script type="text/javascript" src="${contextPath }/js/jquery-1.7.2.js"></script>
	<script type="text/javascript">
	   //var result = false;
	   
	   function check(){
		   var loginName = $("#loginName").val();
		   
		    if("" == loginName) {
			   return;
		   }
		   
		   var button = $("input[type=submit]");
		   $.ajax({
			   url: "${contextPath}/profile/register/check/" + loginName,
			   type: "post",
			   success: function(o){
				   if(o && o.result) {
					   
					   $("#errTip").hide();
					   result = true;
					   button.removeAttr("disabled");
				   } else {
					  
					   $("#errTip").show();
					   //$("#loginName").focus();
					   result = false;
					   button.attr("disabled", "disabled");
				   }
			   },
			   error: function(o){
				   alert("账号首字母必须为字符");
				   button.attr("disabled", "disabled");
			   }
		   });
	   }
</script>
		 
<script type="text/javascript" src="${contextPath }/js/jquery-1.7.2.js"></script>
<script type="text/javascript">    
	
	   
	 function checksamepassword(){
		   
		   var password1 = $("#password").val();
		   var password2 = $("#password1").val();
		   var button = $("input[type=submit]");
		   if(password1==password2){
				   
				   $("#errTip1").hide();
				   result = true;
				   button.removeAttr("disabled");
		   }else{
				   
				   $("#errTip1").show();
			       //$("#password").focus();
				   result = false;
				   button.attr("disabled", "disabled");
		  }
	 }
		
</script> 
<body>
<form action="${contextPath}/profile/register/action" method="post">
  <table width="80%" border="1">
	 <tr>
		 <td>账户:</td>
		 <td> <input type="text" name="loginName" id="loginName" onblur="check()"></td>
	     <span id="errTip" style="color: red; display: none">* 用户名已存在，不可注册！</span>
	 <tr> 
	     <td>用户名称：</td>
	     <td><input type="text" name="userName" id="userName" ></td>
	     
	 </tr>
	 <tr>
		 <td>密码：</td>
		 <td><input type="password" name="password" id="password"  ></td>
	 <tr>
		 <td>确认密码：</td>
		 <td><input type="password"name="password1" id="password1" onblur="checksamepassword()"></td>
	     <span id="errTip1" style="color: red; display: none">* 密码不同，不可注册！</span>
	 </tr>
	 <tr>
		 <td>邮箱:</td>
		 <td><input type="email" name="email" id="email"></td>
	 </tr>
 </table>
         <input type="submit" name="submit" id="submit" ">
  
</form>

</body>
</html>